<?php
/**
 * Created by PhpStorm.
 * User: wbj08
 * Date: 2019/1/28
 * Time: 17:24
 */

global $_W, $_GPC;

if ($_W['ispost']) {
    if (checksubmit('submit')) {
        $adsdata = array(
            'uniacid'   => $_W['uniacid'],
            'ads_pid'   => $_GPC['ads_pid'],
            'ads_type'  => $_GPC['ads_type'],
            'ads_did'   => $_GPC['ads_did'],
            'ads_title' => $_GPC['ads_title'],
            'ads_pic'   => $_GPC['ads_pic'],
            'ads_time'  => $_W['timestamp'],
            'ads_ip'    => $_W['clientip'],
        );

        $res = pdo_insert('dgjy_banner', $adsdata);
        if (!empty($res)) {
            message('恭喜！添加成功！', $this->createWebUrl('ads'), 'success');
        } else {
            message('抱歉！添加失败！', $this->createWebUrl('ads'), 'error');
        }
    }
} else {
    $ads = pdo_fetchall("SELECT * FROM" . tablename('dgjy_banner') . "WHERE uniacid=:uniacid ORDER BY ads_did ASC", array(':uniacid' => $_W['uniacid']));

    load()->func('tpl');
    include $this->template('ads/ads');
}
?>